package network.TCP.copy;

import java.io.*;
import java.net.InetAddress;
import java.net.Socket;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-04-05
 * Time:14:43
 */
public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket(InetAddress.getLocalHost(), 8888);
        sendPicture(socket);
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String data = br.readLine();
        System.out.println(data);
        socket.close();
    }

    public static void sendPicture(Socket socket) throws IOException {
        BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());
        FileInputStream fis = new FileInputStream("C:\\Users\\22954\\Pictures\\63835499935591.png");
        byte[] bytes = fis.readAllBytes();
        bos.write(bytes);
        fis.close();
        socket.shutdownOutput();
    }
}
